home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / cmln1085.arc / FIGURES.HDC < prev    next >
Text File  |  1986-02-27  |  7KB  |  181 lines

  1. @style{topmargin 2 lines, bottommargin 2 line, leftmargin 1 char,
  2. rightmargin 1 char, linewidth 79 chars} 
  3. Figure 1.  GSX CALL AND RETURN.  The graphics program calls GSX
  4. and sends the location of some graphics data to be processed;
  5. GIOS displays it and returns, possibly with some data and status
  6. information.
  7. @newpage
  8. Figure 2.  An example of POLYLINE with 4 points:  (3,-1), (2,4),
  9. (-1,0), (2,3), joined in sequence.
  10. @newpage
  11. Figure 3.  The window parameter block contains the pointers to
  12. the five arrays required by GSX:  CONTRL, INTIN, PTSIN, INTOUT,
  13. and PTSOUT.  Note that CONTRL contains size information for each
  14. of the other four arrays along with the GSX function code.   In
  15. particular, for the PTSIN and PTSOUT arrays, this size
  16. information describes @I{the number of points in the array},
  17. namely n@-{ic} and n@-{oc}, which is one-half the number of
  18. coordinates given in each of the respective arrays.
  19. @newpage
  20. Figure 4.  THE MACHINE CODE INTERFACE TO GSX.   The interface
  21. requires the use of the Turbo-supplied procedure INLINE which
  22. permits hex machine code to be inserted directly into the Pascal
  23. source code.  INLINE is incorporated into the procedure CALLGDOS
  24. which receives a pointer to the window parameter block.  The
  25. Turbo function ADDR() returns an address of its argument which is
  26. compatible with an integer pointer (^integer).
  27.  
  28.  
  29.  
  30. @begin{verbatim}
  31.     TYPE    pinteger : ^INTEGER;    {global declaration}
  32.       :
  33.       :
  34.     PROCEDURE callgdos (ppb : pinteger);
  35.     
  36.      {**************************************************
  37.      * ppb is a pointer to the window parameter block. *
  38.      * The procedure takes this pointer and performs   *
  39.      * the software interrupt 224 for the 8086 CPU.    *
  40.      **************************************************}
  41.  
  42.     BEGIN
  43.        INLINE(
  44.           $52/            {PUSH DX        }
  45.           $51/            {PUSH CX        }
  46.           $B9/$73/$04/        {MOVE CX, 473H        }
  47.           $8B/$56/$04/        {MOVE DX, 04[BP]    }
  48.           $CD/$E0/            {INT 224        }
  49.           $59/            {POP CX            }
  50.           $5A            {POP DX            })
  51.     END;
  52.  
  53.  
  54.  
  55. A call to CALLGDOS would take the form
  56.  
  57.     callgdos( ADDR( parameter_block_array )).
  58. @END{VERBATIM}
  59. @newpage
  60. Figure 5.  SET THE PARAMETER BLOCK.  The procedure SETPBLOCK is
  61. provided to assist with setting the parameter block for the
  62. specific GSX function calls.
  63.  
  64.  
  65. @BEGIN[VERBATIM]
  66.    TYPE    pinteger : ^INTEGER;                {   global   }
  67.    VAR          pb : ARRAY[1..5] OF pinteger; {declarations}
  68.       :
  69.       :
  70.    PROCEDURE setpblock( c, in, pin, out, pout : pinteger );
  71.  
  72.     {****************************************************
  73.     *     c . . . contrl array address            *
  74.     *    in . . . input parameter array address        *
  75.     *   pin . . . input points array address        *
  76.     *   out . . . output parameter array address    *
  77.     *  pout . . . output points array address        *
  78.     ****************************************************}
  79.  
  80.    BEGIN     pb[1] :=    c;    pb[2] :=   in;
  81.                 pb[3] :=  pin;    pb[4] :=  out;
  82.         pb[5] := pout
  83.    END;
  84.  
  85.  
  86.  
  87. A call to SETPBLOCK would take the form
  88.  
  89.  setpblock( ADDR(CONTRL),  ADDR(INTIN),
  90.             ADDR(PTSIN ),  ADDR(INTOUT),
  91.             ADDR(PTSOUT))
  92.  
  93. @END{VERBATIM}
  94. @newpage
  95. Figure 6.  POLYLINE AND INPUTLOCATOR PROCEDURES.
  96. @begin{verbatim}
  97. (a)  POLYLINE is used to draw a sequence of lines defined by any
  98.      array of points of given length.
  99. {***********************************************************************}
  100. PROCEDURE polyline( npts : INTEGER;         {in: no. of coordinate pairs}
  101.                    ptsin : pinteger );      {in: pointer to points array}
  102. {***********************************************************************}
  103. @i[{Array must be loaded with npts coordinate pairs in the form xyxyxyxy.
  104. Pass the ADDR(first element of the array) as the second argument above }]
  105.   VAR    contrl  : ARRAY[1..5] OF INTEGER;
  106.         intin, intout, ptsout : INTEGER;
  107.   BEGIN    contrl[1]:= 6;    contrl[2]:= npts;    contrl[4]:= 0;
  108.     setpblock( addr(contrl), addr( intin), ptsin,
  109.                    addr(intout), addr(ptsout));
  110.     callgdos( addr(pb))
  111.   END;
  112.  
  113. (b)  INPUTLOCATOR permits positioning or sampling a graphics input
  114.      locating device.
  115. {***********************************************************************}
  116. FUNCTION inputlocator( device,          {in: device number for input}
  117.              mode,          {in: 1=request, 2=sample    }
  118.             x, y : INTEGER;   {in: initial coords of locator
  119.                            (request mode only, 
  120.                            ignored if sample mode)}
  121.       VAR finalx, finaly : INTEGER;      {out: final coords of locator}
  122.       VAR     terminator : CHAR      {out: terminator character   }
  123.                 ): INTEGER;   {out: 0 = not successful     
  124.                            >0 = successful         }
  125. {***********************************************************************}
  126.   VAR    contrl : ARRAY[1..5] OF INTEGER;
  127.     ptsin, ptsout : ARRAY[1..2] OF INTEGER;
  128.     intin, intout : INTEGER;
  129.   BEGIN contrl[1] :=  28;
  130.     IF mode = 2 THEN contrl[2] := 0 ELSE contrl[2] := 1;
  131.     contrl[4] := 1;
  132.     intin      := device;
  133.     IF contrl[2] = 1 THEN BEGIN
  134.        ptsin[1] := x;
  135.        ptsin[2] := y
  136.     END {IF};
  137.     setpblock( ADDR(contrl), ADDR( intin), ADDR(ptsin ),
  138.            ADDR(intout), ADDR(ptsout));
  139.     callgdos( ADDR(pb));
  140.     inputlocator := contrl[5];
  141.     finalx       := ptsout[1];
  142.     finaly         := ptsout[2];
  143.     terminator   := CHR(intout)
  144.   END;
  145. @end{verbatim}
  146. @NEWPAGE
  147. Figure 7.  ESCAPE FUNCTION EXAMPLE.  Since most escape functions
  148. differ only in the value assigned to the CONTRL array, the
  149. utility procedure ANSCTL assigns the proper values and calls
  150. CALLGDOS and SETPBLOCK.  Therefore, the calls in the Pascal
  151. source code for most escape functions consists of one line, e.g.
  152. ANSCTL(5,0,0,2) when ENTERGRAPHICS is called.
  153. @begin{verbatim}
  154.  
  155. {*******************************************************************}
  156. PROCEDURE ansctl(a, b, c, d : INTEGER);
  157. {*******************************************************************}
  158.  
  159. @I[{Utility to assign CONTRL values to elements 1,2,4, and 6, then
  160. SETPBLOCK, and CALLGDOS.}]
  161.  
  162.   VAR    contrl  : ARRAY[1..6] OF INTEGER;
  163.     intin, intout, ptsin, ptsout : INTEGER;
  164.   BEGIN    contrl[1] := a;   contrl[2] := b;   contrl[4] := c; 
  165.         contrl[6] := d;
  166.     setpblock( ADDR(contrl), ADDR( intin), 
  167.            ADDR(ptsin ), ADDR(intout),
  168.            ADDR(ptsout));
  169.     callgdos( ADDR(pb))
  170.   END;
  171.  
  172. {*******************************************************************}
  173. PROCEDURE entergraphics;
  174. {*******************************************************************}
  175.  
  176. @i[{Device enters graphics mode from alpha cursor mode}]
  177.  
  178.   BEGIN    ansctl(5,0,0,2)    END;
  179. @END{VERBATIM}
  180.  the calls in the Pascal
  181. sourc